/*
 * 数据库管理工具API
 *
 * @Author:    1024创新实验室-主任：卓大
 * @Date:      2024-01-01 00:00:00
 * @Wechat:    zhuda1024
 * @Email:     lab1024@163.com
 * @Copyright  1024创新实验室 （ https://1024lab.net ），Since 2012
 */
import { getRequest, postRequest } from '/@/lib/axios';

export const databaseManagerApi = {
  /**
   * 获取数据库对象列表 @author 卓大
   */
  getDatabaseObjects: (datasourceId, objectType) => {
    return getRequest(`/database-manager/objects/${datasourceId}`, { objectType });
  },

  /**
   * 执行SQL查询 @author 卓大
   */
  executeQuery: (param) => {
    return postRequest('/database-manager/execute-query', param);
  },

  /**
   * 执行SQL更新 @author 卓大
   */
  executeUpdate: (param) => {
    return postRequest('/database-manager/execute-update', param);
  },

  /**
   * 获取表结构信息 @author 卓大
   */
  getTableStructure: (datasourceId, tableName) => {
    return getRequest(`/database-manager/table-structure/${datasourceId}`, { tableName });
  },

  /**
   * 获取查询历史 @author 卓大
   */
  getQueryHistory: (datasourceId, param) => {
    return getRequest(`/database-manager/query-history/${datasourceId}`, param);
  },
}; 